package pqt;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.Toolkit;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.Color;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class PuestaCero extends JDialog {

	private final JPanel contentPanel = new JPanel();
	JLabel lblNewLabel;
	int count=0;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		try {
			PuestaCero dialog = new PuestaCero();
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog.
	 */
	public PuestaCero() {
		setTitle("Puesta a Cero");
		setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
		setIconImage(Toolkit.getDefaultToolkit().getImage(PuestaCero.class.getResource("/img/icono.png")));
		setBounds(100, 100, 827, 590);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBackground(new Color(204, 204, 204));
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(null);
		
			lblNewLabel = new JLabel("<html><p align='center'>Coloque pesa de XXXX sobre la balanza, luego agregue otra pesa de igual valor a e:zzzz y seleccione la funcion de puesta a cero del equipo bajo ensayo, si puede realizar la puesta a cera seleccione OK, en caso de no poder realizarla, seleccione NO OK</p></html>");
			lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 30));
			lblNewLabel.setBounds(10, 11, 791, 227);
			contentPanel.add(lblNewLabel);
		
		
		//---------------------------------Boton Pasa----------------------------------------------------
			final JButton btnOk = new JButton("");
				btnOk.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						siguienteOpcion();
						
					}
				});
				contentPanel.add(btnOk);
				btnOk.setFocusable(true);
				btnOk.setContentAreaFilled(false);
				btnOk.setBorderPainted(false);
				btnOk.setBorder(null);
				btnOk.setBounds(106, 423, 265, 87);
				btnOk.setIcon(new ImageIcon(testBoton.class.getResource("/img/OkAzulGrande.png")));
				btnOk.setPressedIcon(new ImageIcon(testBoton.class.getResource("/img/OkBlancoGrande.png")));
				btnOk.addMouseListener(new MouseAdapter() {
					@Override
					public void mouseEntered(MouseEvent arg0) {
						btnOk.setIcon(new ImageIcon(testBoton.class.getResource("/img/OkVerdeGrande.png")));
						getRootPane().setDefaultButton(btnOk);
						
					}
					@Override
					public void mouseExited(MouseEvent e) {
						btnOk.setIcon(new ImageIcon(testBoton.class.getResource("/img/OkAzulGrande.png")));
						getRootPane().setDefaultButton(null);
					}
				});
				btnOk.addFocusListener(new FocusAdapter() {
					@Override
					public void focusGained(FocusEvent arg0) {
						btnOk.setIcon(new ImageIcon(testBoton.class.getResource("/img/OkVerdeGrande.png")));
						getRootPane().setDefaultButton(btnOk);
					}
					@Override
					public void focusLost(FocusEvent e) {
						btnOk.setIcon(new ImageIcon(testBoton.class.getResource("/img/OkAzulGrande.png")));
						getRootPane().setDefaultButton(null);
					}
				});
		//------------------------------------------------------------------------------------------------		
				final JButton btnNoOk = new JButton("");
				btnOk.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						//siguienteOpcion();
						
					}
				});
				contentPanel.add(btnNoOk);
				btnNoOk.setFocusable(true);
				btnNoOk.setContentAreaFilled(false);
				btnNoOk.setBorderPainted(false);
				btnNoOk.setBorder(null);
				btnNoOk.setBounds(450, 423, 265, 87);
				btnNoOk.setIcon(new ImageIcon(testBoton.class.getResource("/img/NoOkAzulGrande.png")));
				btnNoOk.setPressedIcon(new ImageIcon(testBoton.class.getResource("/img/NoOkBlancoGrande.png")));
				btnNoOk.addMouseListener(new MouseAdapter() {
					@Override
					public void mouseEntered(MouseEvent arg0) {
						btnNoOk.setIcon(new ImageIcon(testBoton.class.getResource("/img/NoOkRojoGrande.png")));
						getRootPane().setDefaultButton(btnNoOk);
						
					}
					@Override
					public void mouseExited(MouseEvent e) {
						btnNoOk.setIcon(new ImageIcon(testBoton.class.getResource("/img/NoOkAzulGrande.png")));
						getRootPane().setDefaultButton(null);
					}
				});
				btnNoOk.addFocusListener(new FocusAdapter() {
					@Override
					public void focusGained(FocusEvent arg0) {
						btnNoOk.setIcon(new ImageIcon(testBoton.class.getResource("/img/NoOkRojoGrande.png")));
						getRootPane().setDefaultButton(btnNoOk);
					}
					@Override
					public void focusLost(FocusEvent e) {
						btnNoOk.setIcon(new ImageIcon(testBoton.class.getResource("/img/NoOkAzulGrande.png")));
						getRootPane().setDefaultButton(null);
					}
				});
				
				
	}

void siguienteOpcion()
{
	if(count == 0)
	{
	lblNewLabel.setText("<html><p align='center'>Retire de la balanza a e:zzz y seleccione la funcion de puesta a cero del equipo bajo ensayo. Si puede realizar la puesta a cero seleccione OK.</p></html>");
	count++;
	}
	else
	{
		dispose();
	}
}

}
